﻿CREATE PROCEDURE [dbo].[spAddFactTrackSalesIndex]

AS
BEGIN

IF NOT EXISTS(SELECT * FROM sys.indexes WHERE object_id = object_id('FactTrackSales') AND NAME ='NIX_FactTrackSales_Date')
	CREATE NONCLUSTERED INDEX [NIX_FactTrackSales_Date] ON [dbo].[FactTrackSales]
(
	[InvoiceDateId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

IF NOT EXISTS(SELECT * FROM sys.indexes WHERE object_id = object_id('FactTrackSales') AND NAME ='NIX_FactTrackSales_TrackId')
	CREATE NONCLUSTERED INDEX [NIX_FactTrackSales_TrackId] ON [dbo].[FactTrackSales]
(
	[TrackId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

IF NOT EXISTS(SELECT * FROM sys.indexes WHERE object_id = object_id('FactTrackSales') AND NAME ='NIX_FactTrackSales_GenreId')
	CREATE NONCLUSTERED INDEX [NIX_FactTrackSales_GenreId] ON [dbo].[FactTrackSales]
(
	[GenreId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

IF NOT EXISTS(SELECT * FROM sys.indexes WHERE object_id = object_id('FactTrackSales') AND NAME ='NIX_FactTrackSales_MediaTypeId')
	CREATE NONCLUSTERED INDEX [NIX_FactTrackSales_MediaTypeId] ON [dbo].[FactTrackSales]
(
	[MediaTypeId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

IF NOT EXISTS(SELECT * FROM sys.indexes WHERE object_id = object_id('FactTrackSales') AND NAME ='NIX_FactTrackSales_CustomerId')
	CREATE NONCLUSTERED INDEX [NIX_FactTrackSales_CustomerId] ON [dbo].[FactTrackSales]
(
	[CustomerId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

END



